//
//  YWMission.m
//  maintain
//
//  Created by 郑想 on 15/11/4.
//  Copyright © 2015年 ewin. All rights reserved.
//

#import "MJExtension.h"
#import "YWCommonTool.h"
#import "YWEquipment.h"
#import "YWEquipmentManager.h"
#import "YWCommonTool.h"
#import "YWMission.h"
#import "YWLocation.h"
#import "YWHandler.h"
#import "YWEquipmentType.h"
#import "YWBuilding.h"

@implementation YWLocationRel

@end

@implementation YWSite
- (void)mj_keyValuesDidFinishConvertingToObject
{
    if ([self.siteType isEqualToString:@"A"]) {
        self.siteTypeId = YWMissionSiteTypeApartment;
    }
    else if ([self.siteType isEqualToString:@"F"]) {
        self.siteTypeId = YWMissionSiteTypeFloor;
    }
}
@end

@implementation YWMission
+ (NSArray *)mj_ignoredPropertyNames
{
    return @[@"uploadFail",@"read",@"isOpen",@"equipmentsArray",@"totalImageNameArray",@"psText"];
}
@end

@implementation YWEquipmentIdJson
@end

@implementation YWMaintenanceMission
+ (NSArray *)mj_ignoredPropertyNames
{
    return @[@"buildingId",@"equipmentTypeId",@"maintenanceEquipmentId",@"missionRules",@"executorIds",@"observerIds"];
}
+ (NSDictionary*)mj_replacedKeyFromPropertyName
{
    return @{ @"finishTime" : @"completionTime" };
}
+ (NSDictionary*)mj_objectClassInArray
{
    return @{ @"executors" : @"YWHandler",
              @"equipments" : @"YWEquipmentIdJson",
              @"observers" : @"YWHandler",
              @"replies" : @"YWReply"};
}
- (void)mj_keyValuesDidFinishConvertingToObject{
    self.equipmentTypeId = self.equipmentType.equipmentTypeId;
    self.buildingId = self.building.buildingId;
    NSMutableString *atUserName = [[NSMutableString alloc] init];
    [self.observers enumerateObjectsUsingBlock:^(YWHandler*  _Nonnull handler, NSUInteger idx, BOOL * _Nonnull stop) {
        if (atUserName.length && idx!=0) {
            [atUserName appendString:@","];
        }
        [atUserName appendString:[@(handler.uniqueId) stringValue]];
    }];
    self.observerIds = [NSString stringWithFormat:@"%@",atUserName];
    
    if (self.executors) {
        self.executorIds = [YWCommonTool handlerIdsWithHandlerArray:self.executors];
    }
}
@end



@implementation YWTroubleEquipmentTypeJson
@end

@implementation YWTroubleContact
@end


@implementation YWMissionStatusJson
+ (NSDictionary*)mj_objectClassInArray
{
    return @{ @"executors" : @"YWHandler" };
}
@end

@implementation YWTroubleIdJson
@end
